home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / xdme_1.84_src.lha / XDME / Src / Mod / Math.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-29  |  16.8 KB  |  693 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     math.c
  5.  
  6.     DESCRIPTION
  7.     Simple Math commands for DME/XDME (integer only)
  8.     Variable swapping    for DME/XDME
  9.  
  10.     NOTES
  11.     -/-
  12.  
  13.     BUGS
  14.     <none known>
  15.  
  16.     TODO
  17.     erweitertes Math-interfaces (flexibler, mehr funktionen)
  18.  
  19.     EXAMPLES
  20.     [ $a == 10 $b == 11 ]
  21.     inc a            [-> $a == 11]
  22.     add b ( 3 * 4 + $b )    [-> $b == 34]
  23.  
  24.     SEE ALSO
  25.     vars.c
  26.  
  27.     AUTHOR
  28.     Bernd "0" Noll (b_noll@informatik.uni-kl.de)
  29.  
  30.     HISTORY
  31.     <see RCS-File>
  32.     01-10-94 b_noll introduced DEFMESSAGE
  33.  
  34. *!***************************************************************************
  35. *!
  36. *!  integer MATH Functions
  37. *!
  38. ******************************************************************************/
  39.  
  40. /*
  41. **  (C)Copyright 1992 by Bernd Noll for null/zero-soft
  42. **  All Rights Reserved
  43. **
  44. **  RCS Header: $Id: Math.c 1.2 1994/09/20 11:05:32 b_noll Exp b_noll $
  45. **
  46. **
  47. */
  48.  
  49. /**************************************
  50.         Includes
  51. **************************************/
  52. #include "defs.h"
  53. #ifdef PATCH_NULL
  54. #include "COM.h"
  55. #include "libs/AUTO.h"
  56. #endif
  57.  
  58. /**************************************
  59.         Globale Exports
  60. **************************************/
  61. //Prototype char    MathInfix;
  62. Prototype void      do_unnamedmathfunc(void);
  63. Prototype void      do_namedmathfunc  (void);
  64. Prototype void      do_infixmode        (void);
  65. Prototype void      do_swapV        (void);
  66.  
  67.  
  68. /**************************************
  69.       Interne Defines & Strukturen
  70. **************************************/
  71. /* --- math-function-modi if math_func_helper doesn't use function-parameters */
  72.  
  73. #define MODE_ADD simplehash('a','d')  /* x = x+y (2) */
  74. #define MODE_DEC simplehash('d','e')  /* x = x-1 (1) */
  75. #define MODE_DIV simplehash('d','i')  /* x = x/y (2) */
  76. #define MODE_INC simplehash('i','n')  /* x = x+1 (1) */
  77. #define MODE_MOD simplehash('m','o')  /* x = x%y (2) */
  78. #define MODE_MUL simplehash('m','u')  /* x = x*y (2) */
  79. #define MODE_NEG simplehash('n','e')  /* x = -x  (1) */
  80. #define MODE_NOT simplehash('n','o')  /* x = ~x  (1) */
  81. #define MODE_SUB simplehash('s','u')  /* x = x-y (2) */
  82.  
  83. #ifndef MAXIA
  84. #define MAXIA 5
  85. #endif
  86.  
  87. #define OP_SUB 1  /* the values are used for priorities, too */
  88. #define OP_ADD 2
  89. #define OP_DIV 3
  90. #define OP_MOD 4
  91. #define OP_MUL 5
  92.  
  93. /**************************************
  94.        Interne Prototypes
  95. **************************************/
  96.  
  97.  
  98. /**************************************
  99.        Impementation
  100. **************************************/
  101.  
  102.  
  103. /*
  104. *!
  105. *!  math functions offer the user a simple calculator,
  106. *!  which recognizes +,-,*,/,%,(,);
  107. *!  2 numbers must be separated with one operator,
  108. *!  !!each operator must be surrounded with whitespaces!!
  109. *!  (there are no unique +/- operators allowed, if they are
  110. *!   not part of a number, so "-1" is allowed, "(- 1)" is not!)
  111. *!
  112. *!  so each expression has an inequal number of subexpressions -
  113. *!  x+1 values and x operators with x in N
  114. *!  there should not be more than MAXIA (== 5)
  115. *!  expressions on one level (simply use brackets)
  116. *!  ( that is in fact no problem, as on any evaluation
  117. *!    we try to shorten our results due to operator prorities,
  118. *!    and as long as there are only 4 operators used, we do
  119. *!    normally not run out of space
  120. *!   e.g.:> set abc 0 add abc (1 * 2 + 3 * 4 / 5 - 6) title $abc
  121. *!    => 1      => 1*    => 1*2   => 1*2+   [-> 2+]
  122. *!    => 2+3      => 2+3*  => 2+3*4 => 2+3*4/ [-> 2+12/]
  123. *!    => 2+12/5 => 2+12/5- [-> 2+2-] [-> 4-] => 4-6
  124. *!    == -2
  125. *!
  126. */
  127.  
  128. static
  129. long domathop (long a1, char op, long a2)
  130. {
  131.     switch (op)
  132.     {
  133.     case OP_ADD:
  134.     return (a1 + a2);
  135.     case OP_SUB:
  136.     return (a1 - a2);
  137.     case OP_MUL:
  138.     return (a1 * a2);
  139.     case OP_DIV:
  140.     return (a1 / a2);
  141.     case OP_MOD:
  142.     return (a1 % a2);
  143.     default:
  144. DEFMESSAGE( _MATH_unknown_operator, "Math:\nunknown operator `%s'" )
  145.     error  (_MATH_unknown_operator, "?");
  146.     return (0);
  147.     } /* switch */
  148. } /* domathop */
  149.  
  150.  
  151. static
  152. char getmathop (char * str)
  153. {
  154.     if (!str)
  155.     {
  156.     return(0);
  157.     } /* if */
  158.  
  159.     switch (*str)
  160.     {
  161.     case '+':
  162.     return (OP_ADD);
  163.     case '-':
  164.     return (OP_SUB);
  165.     case '*':
  166.     return (OP_MUL);
  167.     case '/':
  168.     return (OP_DIV);
  169.     case '%':
  170.     return (OP_MOD);
  171.     default:
  172. DEFMESSAGE( _MATH_unknown_operator, "Math:\nunknown operator `%s'" )
  173.     error (_MATH_unknown_operator, str);
  174.     return(0);
  175.     } /* switch */
  176. } /* getmathop */
  177.  
  178. /* static */
  179. long getmathresult (char* expr)
  180. {
  181.     long   values[MAXIA];
  182.     char   funcs [MAXIA];
  183.     char * str = expr;
  184.     int    i;
  185.     char * checker;
  186.     char * aux2  = NULL;
  187.     char * dummy = NULL;
  188.     char   quote = 0;
  189.  
  190.     /* --------- erstes argument muss immer existieren */
  191.     if (!expr)
  192.     {
  193. DEFMESSAGE( _MATH_empty_expression, "empty expression\n(%sNIL)" )
  194.     error (_MATH_empty_expression, "Input ");
  195.     return(0);
  196.     } /* if */
  197.  
  198.     if (is_number(expr))
  199.     {
  200.     return(atoi(expr));
  201.     } /* if */
  202.  
  203.     checker = (UBYTE *)breakout(&str, "e, &aux2);
  204.     if (!checker)
  205.     {
  206. #if 0
  207.     if (aux2) { free (aux2); aux2 = NULL; } /* if */ /* seems senseless */
  208. #endif
  209. DEFMESSAGE( _MATH_empty_expression, "empty expression\n(%sNIL)" )
  210.     error (_MATH_empty_expression, "breakout ");
  211.     return(0);
  212.     } /* if */
  213.  
  214.     /* PATCH_NULL [07 Apr 1993] : BUGFIX >>> */
  215.     /* now we are testing : 1. result word starts w/ alpha, 2. word was NOT multiword (AND is nonnumber), 3. word is NOT quoted (AND is not number)  */
  216.     if (isalpha(checker[0]) || ((str == NULL || *str == 0) && (quote == 0))) { /* should be better : check up to the first space, if there is a non-digit */
  217.     if (aux2)
  218.         free(aux2);
  219. DEFMESSAGE( _MATH_nonnumber, "non-number to math-function" )
  220.     error (_MATH_nonnumber);
  221.     return (0);
  222.     } /* if */
  223.     /* PATCH_NULL [07 Apr 1993] : BUGFIX <<< */
  224.  
  225.     values[0] = getmathresult ( checker );
  226.     if (aux2)
  227.     {
  228.     free (aux2);
  229.     aux2 = NULL;
  230.     } /* if */
  231.  
  232.     i = 0;
  233.  
  234.     while (!IS_ABORTED() && str && ( 1/* first checking here */ ))
  235.     {
  236.  
  237.     /* --------- operator holen  - better put that line into the while-condition */
  238.     checker = (UBYTE *)breakout(&str, (void*)&dummy, &aux2);
  239.     if (!checker)
  240.     {
  241. #if 0
  242.         if (aux2) { free (aux2); aux2 = NULL; } /* if */ /* seems senseless */
  243. #endif
  244.  
  245.         goto ende;
  246.     } else
  247.     {
  248.  
  249.         funcs[i] = getmathop(checker);
  250.         if (aux2)
  251.         {
  252.         free (aux2);
  253.         aux2 = NULL;
  254.         } /* if */
  255.  
  256.         if (IS_ABORTED())
  257.         {
  258. /* printf ("abort unbekannt\n"); */
  259.         return (0);
  260.         } /* if (aborted) */
  261.  
  262.         /* --------- wenn möglich, verkuerzen */
  263.         while (i>0 && funcs[i-1] >= funcs[i])
  264.         {
  265.         values[i-1] = domathop(values[i-1], funcs[i-1], values[i]);
  266.         funcs[i-1]  = funcs[i];
  267.         i--;
  268.         } /* while */
  269.  
  270.         i++;
  271.         if (i >= MAXIA)
  272.         {
  273. DEFMESSAGE( _MATH_expression_too_complex, "Expression too complex:\n%s" )
  274.         error (_MATH_expression_too_complex, expr);
  275.         return (0);
  276.         } /* if */
  277.  
  278.         /* --------- naechstes argument holen */
  279.         checker   = (UBYTE *)breakout(&str, (void*)&dummy, &aux2);
  280.  
  281.         values[i] = getmathresult(checker);
  282.         if (aux2)
  283.         {
  284.         free (aux2);
  285.         } /* if */
  286.         if (IS_ABORTED())
  287.         {
  288.         return (0);
  289.         } /* if */
  290.     } /* if ex operator */
  291.     } /* while not end of expr */
  292.  
  293. ende:
  294.  
  295.     while (i > 0)
  296.     {
  297.     values[i-1] = domathop(values[i-1], funcs[i-1], values[i]);
  298.     i--;
  299.     } /* while */
  300.  
  301. /* printf("ok %ld\n", values[0]); */
  302.  
  303.     return (values[0]);
  304. } /* getmathresult */
  305.  
  306.  
  307.  
  308. /*
  309. **  math_hash()
  310. **    Calculate the right math-function defined by a string
  311. **
  312. */
  313.  
  314. static
  315. int math_hash (char * str)
  316. {
  317.     switch (str[1]) { /* PATCH_NULL [04 Aug 1993] : BUGFIX */
  318.     case '=':
  319.         switch (str[0])
  320.         {
  321.         case '+':
  322.             return(MODE_ADD);
  323.         case '-':
  324.             return(MODE_SUB);
  325.         case '*':
  326.             return(MODE_MUL);
  327.         case '/':
  328.             return(MODE_DIV);
  329.         case '%':
  330.             return(MODE_MOD);
  331.         case '~':
  332.         case '^':
  333.             return(MODE_NOT);   /* nun ja minus statt NOT ... */
  334.         } /* switch */
  335.     case '-':
  336.         return(MODE_DEC);
  337.     case '+':
  338.         return(MODE_INC);
  339.     default:
  340.         return(simplehash(str[0],str[1]));
  341.     } /* if */
  342. } /* math_hash */
  343.  
  344.  
  345.  
  346. /*
  347. *!  MATH
  348. *!
  349. *!  math-commands, they are all implemented in do_mathfunc
  350. *!
  351. *!  Very simple syntax:
  352. *!
  353. *!  >[MATH1] NEG / INC / DEC / NOT     <varname>
  354. *!  >[MATH2] ADD / SUB / MUL / DIV / MOD <varname> (<value>)
  355. *!
  356. *!    <value>   is a valid dezimal number
  357. *!    <varname> must be given at each function and must be the name
  358. *!          of an existing variable containing a valid number
  359. *!
  360. *!  (a simple hack to do some increment etc. without arexx)
  361. *!
  362. *!  (due to less feedback, all the math commands are planned
  363. *!  to be replaced with one single command MATH name value)
  364. *!
  365. */
  366.  
  367. static
  368. void do_mathfunc (char* mmode, char* vname, char* mval)
  369. {
  370.     int   mathfunc;
  371.     char  str[16];
  372.     long  l1;
  373.     long  l2;
  374.     char* sstr;
  375.     int   type;
  376.  
  377.     type = VAR_NEX;        /* initialise */
  378.     str[15] = '\0';
  379.     l2 = 0;
  380.     /* l1 = 0; */
  381.  
  382.     /* --- get the right operation mode */
  383.     mathfunc = math_hash(mmode);   /* recognize the mathfunction via mmode */
  384.  
  385.     /* --- if necessary and existing, get the 2nd argument */
  386.     if ((mathfunc != MODE_NOT)&& (mathfunc != MODE_NEG)&&
  387.     (mathfunc != MODE_INC)&& (mathfunc != MODE_DEC))
  388.     {
  389.             /* called with 2 arguments => read a number from slot 2 */
  390.     if (mval != NULL)
  391.     {
  392.         if (is_number(mval))
  393.         {
  394.         l2 = atol(mval);
  395.         } else
  396.         {
  397. /* Abortcommand = 0; */
  398. DEFMESSAGE( _MATH_invalid_2nd_argument, "%s:\ninvalid 2nd argument %s" )
  399. /* error (_MATH_invalid_2nd_argument, av[0], mval); */
  400.         l2 = getmathresult (mval);
  401.         if (IS_ABORTED())
  402.         {
  403.             return;
  404.         } /* if */
  405. /* abort2(); */
  406.         } /* if */
  407.     } else
  408.     {
  409. DEFMESSAGE( _MATH_missing_2nd_operand, "Math:\nMissing 2nd Operand!" )
  410.         error (_MATH_missing_2nd_operand);
  411.         abort2();
  412.     } /* if */
  413.     } /* if */
  414.  
  415.     /* --- try to get the type and contents of the variable represented by the 1st argument */
  416.     if (vname != NULL) {        /* get the number in the variable whose name is in slot 1 */
  417.     sstr = GetTypedVar(vname,&type);
  418.     if ((type != VAR_NEX) && is_number(sstr))
  419.     {
  420.         l1 = atol(sstr);
  421.         if (sstr)
  422.         free(sstr);
  423.     } else
  424.     {
  425.         if (sstr)
  426.         free(sstr);
  427. DEFMESSAGE( _MATH_invalid_1st_argument, "%s:\ninvalid 1st argument %s" )
  428.         error (_MATH_invalid_1st_argument, av[0], vname);
  429.         abort2();
  430.     } /* if */
  431.     } else
  432.     {
  433. DEFMESSAGE( _MATH_missing_1st_argument, "%s:\nmissing 1st argument %s" )
  434.     error (_MATH_missing_1st_argument, av[0]);
  435.     abort2();
  436.     } /* if */
  437.  
  438.     /* --- do the specified math operation */
  439.     switch (mathfunc) {         /* apply the math-function to the numbers */
  440.                 /* it would be finer to use a function-variable  - next time perhaps */
  441.     case MODE_NEG:
  442.         l2 = -l1;
  443.         break;
  444.     case MODE_NOT:
  445.         l2 = ~l1;
  446.         break;
  447.     case MODE_INC:
  448.         l2 = l1+1;
  449.         break;
  450.     case MODE_DEC:
  451.         l2 = l1-1;
  452.         break;
  453.     case MODE_ADD:
  454.         l2 = l1+l2;
  455.         break;
  456.     case MODE_SUB:
  457.         l2 = l1-l2;
  458.         break;
  459.     case MODE_MUL:
  460.         l2 = l1*l2;
  461.         break;
  462.     case MODE_DIV:
  463.         if (l2!=0)
  464.         {
  465.         l2 = l1/l2;
  466.         } else
  467.         {
  468. DEFMESSAGE( _MATH_division_by_0, "Math:\nDivision by Zero!" )
  469.         error (_MATH_division_by_0);
  470.         abort2();
  471.         } /* if */
  472.         break;
  473.     case MODE_MOD:
  474.         if (l2!=0)
  475.         {
  476.         l2 = l1%l2;
  477.         } else
  478.         {
  479. DEFMESSAGE( _MATH_division_by_0, "Math:\nDivision by Zero!" )
  480.         error (_MATH_division_by_0);
  481.         abort2();
  482.         } /* if */
  483.         break;
  484.     default:
  485. DEFMESSAGE( _MATH_unknown_operator, "Math:\nunknown operator `%s'" )
  486.         error (_MATH_unknown_operator, "?" );
  487.         abort2();
  488.     } /* switch */
  489.  
  490.     if ((type == VAR_TF) || (type == VAR_GF) /* || (type == VAR_SF) || (type == VAR_PF) */) /* if dest is flag change to boolean */
  491.     l2 = (l2 != 0);
  492.  
  493.     /* --- write back the value , if necessary */
  494.     if ((l2 != l1)) {   /* the function has changed a value => put it back to its variable */
  495.     sprintf(str,"%ld",l2);
  496.  
  497.     SetTypedVar(vname, str, type);
  498.     } /* if */
  499.  
  500. } /* do_mathfunc */
  501.  
  502.  
  503.  
  504. /*
  505. *!  SMATH Interface:
  506. *!
  507. *!  consisting of 8 short mathfuncs:
  508. *!
  509. *!  >INC/ DEC/ NEG/ NOT       x
  510. *!  >ADD/ SUB/ MUL/ DIV/ MOD  x y
  511. *!
  512. *!  which expect 1 or 2 arguments
  513. *!  their function is recognized with their name
  514. *!  since they all use the same routines.
  515. *!
  516. *!  (in fact these functions are abbreviations of MATH?)
  517. *!
  518. */
  519.  
  520. void do_namedmathfunc (void)
  521. {
  522.     do_mathfunc(av[0], av[1], av[2]);
  523. } /* do_namedmathfunc */
  524.  
  525.  
  526. /*
  527. *!  LMATH Interface:
  528. *!
  529. *!  2 long math-functions:
  530. *!
  531. *! >MATH1 x y
  532. *! >MATH2 x y z
  533. *!
  534. *!  which expect 2 or 3 arguments
  535. *!
  536. *!  If You use the Toggle INFIX
  537. *!  the second argument defines the mathematical function
  538. *!  else the first arg does
  539. *!
  540. *!
  541. *! >INFIX bool
  542. *!
  543. *!  define the argument order of the MATH? commands
  544. *!  with INFIX OFF we say
  545. *!   % MATH? operator variable [value]
  546. *!  with INFIX ON we use
  547. *!   % MATH? variable operator [value]
  548. *!
  549. */
  550.  
  551.  
  552. // char MathInfix = 0;
  553.  
  554.  
  555. void do_unnamedmathfunc (void)
  556. {
  557.     if (MathInfix)
  558.     do_mathfunc(av[2], av[1], av[3]); /* infix notation */
  559.     else
  560.     do_mathfunc(av[1], av[2], av[3]); /* prefix notation */
  561. } /* do_unnamedmathfunc */
  562.  
  563.  
  564.  
  565. void do_infixmode (void)
  566. {
  567.     MathInfix = test_arg (av[1], MathInfix);
  568. DEFMESSAGE( _MATH_infixmode, "Math Infixmode %s" )
  569.     title (_MATH_infixmode,
  570.     MathInfix? __on: __off);
  571. } /* do_infixmode */
  572.  
  573.  
  574. /*
  575. *! >SWAP var1 var2
  576. *!
  577. *!  Swap the contents of 2 variables
  578. *!
  579. *!  the command should recognize the type of the 2 variables and
  580. *!  use the appropriate set-funcions
  581. *!
  582. */
  583.  
  584. void do_swapV (void)
  585. {
  586.     char*   value[2];
  587.     int     type[2];
  588.     int     i;
  589.  
  590.     /* --- read values */
  591.     for (i = 0; i < 2; i++)
  592.     {
  593.     if (!(value[i] = GetTypedVar(av[1+i], &type[i])))
  594.     {
  595. DEFMESSAGE( _MATH_unknown_variable, "%s:\nUnknown Variable '%s'!" )
  596.         error (_MATH_unknown_variable, av[0], av[1+i]);
  597.         goto abortion;
  598.     } /* if */
  599.     } /* for */
  600.  
  601. #ifdef N_DEF
  602.     /* --- check compability */
  603.     for (i = 0; i < 2; i++)
  604.     {
  605.     switch (type[i])
  606.     {
  607.         case VAR_TF:
  608.         case VAR_GF:
  609.         /* case VAR_PF:
  610.         case VAR_SF: */
  611.         dummy = toggler(1,value[1-i]);
  612.         break;
  613.         case VAR_NEX:
  614. DEFMESSAGE( _MATH_unknown_variable, "%s:\nUnknown Variable '%s'!" )
  615.         error (_MATH_unknown_variable, av[0], av[1+i]);
  616.         goto abortion;
  617.     } /* switch */
  618.     } /* for */
  619.  
  620.     if (aborted)
  621.     {
  622. DEFMESSAGE( _MATH_inkompatible_values, "%s:\nIncompatible values for\n'%s' and '%s'!" )
  623.     /* error (_MATH_inkompatible_values, av[0], av[1], av[2]); */
  624.     goto abortion;
  625.     }
  626. #endif /*  */
  627.  
  628.  
  629.     /* --- Write & free values */
  630.     for (i = 0; i < 2; i++)
  631.     {
  632.     SetTypedVar(av[2-i], value[i], type[1-i]);
  633.     free (value[i]);
  634.     } /* for */
  635.  
  636.     return;
  637.  
  638. abortion:
  639.     free(value[0]);
  640.     free(value[1]);
  641.     abort2();
  642. } /* do_swapV */
  643.  
  644.  
  645. DEFUSERCMD("math1", 2, CF_VWM|CF_ICO|CF_COK, void, do_unnamedmathfunc, (void),;)
  646. DEFUSERCMD("math2", 3, CF_VWM|CF_ICO|CF_COK, void, do_unnamedmathfunc, (void),;)
  647. DEFUSERCMD("infixmode", 1, CF_VWM|CF_ICO|CF_COK, void, do_infixmode, (void),;)
  648. DEFUSERCMD("inc", 1, CF_VWM|CF_ICO|CF_COK, void, do_namedmathfunc, (void),;)
  649. DEFUSERCMD("sub", 2, CF_VWM|CF_ICO|CF_COK, void, do_namedmathfunc, (void),;)
  650. DEFUSERCMD("add", 2, CF_VWM|CF_ICO|CF_COK, void, do_namedmathfunc, (void),;)
  651. DEFUSERCMD("dec", 1, CF_VWM|CF_ICO|CF_COK, void, do_namedmathfunc, (void),;)
  652. DEFUSERCMD("div", 2, CF_VWM|CF_ICO|CF_COK, void, do_namedmathfunc, (void),;)
  653. DEFUSERCMD("mod", 2, CF_VWM|CF_ICO|CF_COK, void, do_namedmathfunc, (void),;)
  654. DEFUSERCMD("mul", 2, CF_VWM|CF_ICO|CF_COK, void, do_namedmathfunc, (void),;)
  655. DEFUSERCMD("not", 1, CF_VWM|CF_ICO|CF_COK, void, do_namedmathfunc, (void),;)
  656. DEFUSERCMD("neg", 1, CF_VWM|CF_ICO|CF_COK, void, do_namedmathfunc, (void),;)
  657. DEFUSERCMD("swapv", 2, CF_VWM|CF_ICO|CF_COK, void, do_swapV, (void),;)
  658. /*DEFHELP #cmd math MATH1 arg1 arg2 - long version for NOT INC NEG DEC; $INFIXMODE decides if arg1 or arg2 is operator, the other arg is variablename */
  659. /*DEFHELP #cmd math MATH2 arg1 arg2 arg3 - long version for MUL MOD DIV SUB ADD; $INFIXMODE decides if arg1 or arg2 is operator, the other arg is variablename */
  660. /*DEFHELP #cmd math INC var - increment the value of @{B}var@{UB} */
  661. /*DEFHELP #cmd math DEC var - decrement the value of @{B}var@{UB} */
  662. /*DEFHELP #cmd math NEG var - negate the value of @{B}var@{UB} */
  663. /*DEFHELP #cmd math NOT var - logical not for the value of @{B}var@{UB} */
  664. /*DEFHELP #cmd math ADD var val - add @{B}val@{UB} to the value of @{B}var@{UB} */
  665. /*DEFHELP #cmd math SUB var val - sub @{B}val@{UB} from the value of @{B}var@{UB} */
  666. /*DEFHELP #cmd math MUL var val - multiply the value of @{B}var@{UB} with @{B}val@{UB} */
  667. /*DEFHELP #cmd math MOD var val - modulo divide the value of @{B}var@{UB} with @{B}val@{UB} */
  668. /*DEFHELP #cmd math DIV var val - divide the value of @{B}var@{UB} with @{B}val@{UB} */
  669. /*DEFHELP #cmd var SWAPV var1 var2 - try to swap the contents of 2 variables */
  670.  
  671.  
  672.  
  673. #ifdef STATIC_COM /* PATCH_NULL < 24-06-94 */
  674.  
  675.     DEFFLAG( 93-04-09, MathInfix, 0 )
  676.  
  677. #endif
  678.  
  679. #ifdef SPC_VAR
  680.  
  681. generic global bit infixmode = %{
  682.     reference = "MathInfix";
  683.     help      = %[ the decision, if MATH1 and MATH2 do use prefixed (e.g.% MATH1 ++ count) or infixed (e.g. MATH2 count += 10) operators. %];
  684.     gendate   = "01-01-93/1";
  685.     initval   = "0";
  686. %};
  687.  
  688. #endif
  689.  
  690. /******************************************************************************
  691. *****  ENDE math.c
  692. ******************************************************************************/
  693.